<?php
/**
 *  💡 免责声明：本软件不得用于商业用途，仅做学习交流
 *  ⚠️ 权利声明：本软件由版权人提供产品技术支持
 *  📅 项目编号：NX2025-0135
 */
namespace App\Admin\Actions\Row;

use App\Models\MemberTopupOrder;
use App\Service\User\WalletAccountService;
use Dcat\Admin\Grid\RowAction;
use Illuminate\Http\Request;

class MemberTopoupOrderApproveAction extends RowAction
{
    protected $title = '✅ 通过';

    public function handle(Request $request)
    {
        $model = MemberTopupOrder::query()->findOrFail($this->getKey());
        $model->review = 1;
        $model->save();
        WalletAccountService::make()->recharge($model->user_id, $model->amount);
        return $this->response()
            ->success('审核通过！资金已进入会员钱包')
            ->refresh();
    }

    public function confirm()
    {
        return '确定要通过审核吗？通过后资金进入会员钱包！';
    }
}
